package ${package.Controller};

import org.springframework.web.bind.annotation.RequestMapping;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import ${package.Entity}.ResponseResult;
import ${package.Service}.${table.serviceName};
import org.springframework.beans.factory.annotation.Autowired;
import ${package.Entity}.${table.entityName};

<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
import ${package.Other}.${table.entityPath}.DeleDTO;
import ${package.Other}.${table.entityPath}.ListDTO;

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

   @Autowired
   private ${table.serviceName} ${table.entityPath}Service;


   /**
   * ${table.comment!} 新增
   * @param ${table.entityPath}
   * @return
   */
   @PostMapping("/add")
   public ResponseResult add(@Validated @RequestBody ${table.entityName} ${table.entityPath}){
        return ${table.entityPath}Service.add(${table.entityPath});
   }

   /**
   * ${table.comment!} 删除
   * @param deleDTO
   * @return
   */
   @PostMapping("/dele")
   public ResponseResult dele(@Validated @RequestBody DeleDTO deleDTO){
        return ${table.entityPath}Service.dele(deleDTO);
   }

    /**
    * ${table.comment!} 信息
    * @param ${table.fields[0].propertyName}
    * @return
    */
    @GetMapping("/info")
    public ResponseResult info(@RequestParam Integer ${table.fields[0].propertyName}){
        return  ${table.entityPath}Service.info( ${table.fields[0].propertyName});
    }

    /**
    * 编辑 ${table.comment!}
    * @param ${table.entityPath}
    * @return
    */
    @PostMapping("/edit")
    public ResponseResult edit(@Validated @RequestBody  ${table.entityName} ${table.entityPath}){
        return  ${table.entityPath}Service.edit(${table.entityPath});
    }

    /**
    * ${table.comment!} 列表
    * @param listDTO
    * @return
    */
    @PostMapping("/list")
    public ResponseResult listPage(@Validated @RequestBody ListDTO listDTO){
    return  ${table.entityPath}Service.listPage(listDTO);
    }

}
</#if>
